﻿package com.game.utils {
	public class TowerType {
		public static const NONE:TowerType= new TowerType( "None",   -1 );
		public static const BULLET:TowerType= new TowerType( "Bullet", 0 );
		public static const SLOW:TowerType= new TowerType( "Slow", 1 );
		public static const ROCKET:TowerType= new TowerType( "Rocket", 2 );
		public static const FIRE:TowerType= new TowerType( "Fire", 3 );
		public static const SPARK:TowerType= new TowerType( "Spark", 4 );
		public static const WAVE:TowerType= new TowerType( "Wave", 5);
		public var value:String;
		public var ordinal:int;
		public function TowerType( value:String, ordinal:int) {
			this.value = value;
			this.ordinal = ordinal;
		}
		public static function inArray(value:String ):TowerType {
			for (var i:int=0; i<list.length; i++) {
				if (list[i].value == value) {
					return list[i];
				}
			}
			return NONE;
		}
		public static function get list( ):Array {
			return [NONE,BULLET,SLOW,ROCKET,FIRE,SPARK,WAVE];
		}
		/**
		 * 
		 * @return page list array
		 * 
		 */
		public static function get cList( ):Array {
			var cList:Array = TowerType.list;
			cList.unshift( NONE );
			return cList;
		}
		/**
		 * Checks equality of enum type 
		 * @param enum
		 * @return equality check
		 * 
		 */
		public function equals( enum:TowerType ):Boolean {
			return ( this.ordinal == enum.ordinal && this.value == enum.value );
		}
		public function toString():String {
			return this.value;
		}
	}
}